package com.atguigu.gmall.product.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;

/**
 * @author: 李旭
 * @create: 2021-08-27 16:05
 **/
@Controller
@RequestMapping
public class HelloController {

    //Thymeleaf入门程序
    @GetMapping("/hello")
    public String hello(Model model, HttpSession session){

        model.addAttribute("hello","世界你好");

        session.setAttribute("h","大家好才是真的好");

        List<String> list = new ArrayList<>();
        list.add("刘德华");
        list.add("刘能");
        list.add("熊大");
        model.addAttribute("list",list);
        //数字
        model.addAttribute("num",10);
        //回显数据 要求字体颜色是绿色
        model.addAttribute("gname","<span style=\"color:green\">宝强</span>");


        return "hello";//SpringMVC的前缀 后缀是一样的
    }
}
